package com.kotlin.lib

fun main() {
    val map = HashMap<String, Array<Int>>()
    val databaseSize = 10
    val tableEachDatabase = 30
    for (userId in 10000..1000000) {
        val mode = userId % databaseSize
        val key = "database_${mode}"
        val value = map[key] ?: Array<Int>(tableEachDatabase) { 0 }
        val tableIndex = (userId / databaseSize) % tableEachDatabase
        value[tableIndex] += 1
        map[key] = value
    }

    map.forEach {
        val key = it.key
        it.value.forEachIndexed { index, i ->
            println("$key table $index has $i records")
        }
    }


}

